use anyhow::Result;
use derive_more::{Add, Display, From, Into};

#[derive(PartialEq, From, Add, Debug, Display, Copy, Clone)]
struct MyInt(i32);

#[derive(PartialEq, From, Into)]
struct Point2D {
    x: i32,
    y: i32,
}

#[allow(unused)]
#[derive(PartialEq, From, Add, Display)]
enum MyEnum {
    #[display("int: {_0}")]
    Int(i32),
    Uint(u32),
    #[display("nothing")]
    Nothing,
}

fn main() -> Result<()> {
    let my_int: MyInt = 10.into();
    let v = my_int + 20.into();
    println!("{v}");
    let v1: MyInt = v;
    println!("{v1}");

    assert_eq!(MyInt(11), MyInt(5) + 6.into());
    assert_eq!((5, 6), Point2D { x: 5, y: 6 }.into());
    assert!(MyEnum::Int(15) == (MyEnum::Int(8) + 7.into())?);
    assert_eq!(MyEnum::Int(15).to_string(), "int: 15");
    assert_eq!(MyEnum::Uint(42).to_string(), "42");
    assert_eq!(MyEnum::Nothing.to_string(), "nothing");

    Ok(())
}
